package cn.yangsen.simplebeanmanager.bean.html;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import cn.yangsen.simplebeanmanager.bean.html.itfc.Disable;
import cn.yangsen.simplebeanmanager.bean.html.itfc.OnClickAble;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;

@XStreamAlias("input")
@ToString
public abstract class Input extends Element implements Disable, OnClickAble
{
	@Getter
	@Setter
	@XStreamAsAttribute
	private String name;

	@Getter
	@Setter
	@XStreamAsAttribute
	private String value;

	@XStreamAsAttribute
	private String disabled;

	@XStreamAsAttribute
	@Setter
	private String onClick;

	public abstract InputType getType();

	@Override
	public void setDisabled(boolean disabled)
	{
		if (disabled)
		{
			this.disabled = "disabled";
		}
		else
		{
			this.disabled = null;
		}
	}
}

enum InputType
{
	Text,
	Checkbox,
	Radio,
	Hidden,
	Submit,
	Button,
	File
}
